home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / MINMAX.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-03-01  |  7.0 KB  |  138 lines

  1. (*----------------------------------------------------------------------*)
  2. (*               Min --- Find minimum of two integers                   *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Min( A, B: INTEGER ) : INTEGER;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*   Function: Min                                                      *)
  10. (*                                                                      *)
  11. (*   Purpose:  Returns smaller of two numbers                           *)
  12. (*                                                                      *)
  13. (*   Calling sequence:                                                  *)
  14. (*                                                                      *)
  15. (*      Smaller := MIN( A , B ) : INTEGER;                              *)
  16. (*                                                                      *)
  17. (*         A       --- 1st input integer number                         *)
  18. (*         B       --- 2nd input integer number                         *)
  19. (*         Smaller --- smaller of A, B returned                         *)
  20. (*                                                                      *)
  21. (*                                                                      *)
  22. (*   Calls:  None                                                       *)
  23. (*                                                                      *)
  24. (*                                                                      *)
  25. (*----------------------------------------------------------------------*)
  26.  
  27. BEGIN (* Min *)
  28.  
  29.    IF A < B THEN
  30.       Min := A
  31.    ELSE
  32.       Min := B;
  33.  
  34. END   (* Min *);
  35.  
  36. (*----------------------------------------------------------------------*)
  37. (*               Max --- Find maximum of two integers                   *)
  38. (*----------------------------------------------------------------------*)
  39.  
  40. FUNCTION Max( A, B: INTEGER ) : INTEGER;
  41.  
  42. (*----------------------------------------------------------------------*)
  43. (*                                                                      *)
  44. (*   Function:  Max                                                     *)
  45. (*                                                                      *)
  46. (*   Purpose:  Returns larger of two numbers                            *)
  47. (*                                                                      *)
  48. (*   Calling sequence:                                                  *)
  49. (*                                                                      *)
  50. (*      Larger := MAX( A , B ) : INTEGER;                               *)
  51. (*                                                                      *)
  52. (*         A       --- 1st input integer number                         *)
  53. (*         B       --- 2nd input integer number                         *)
  54. (*         Larger  --- Larger of A, B returned                          *)
  55. (*                                                                      *)
  56. (*                                                                      *)
  57. (*   Calls:  None                                                       *)
  58. (*                                                                      *)
  59. (*----------------------------------------------------------------------*)
  60.  
  61. BEGIN (* Max *)
  62.  
  63.    IF A > B THEN
  64.       Max := A
  65.    ELSE
  66.       Max := B;
  67.  
  68. END   (* Max *);
  69.  
  70. (*----------------------------------------------------------------------*)
  71. (*               Rmin --- Find minimum of two reals                     *)
  72. (*----------------------------------------------------------------------*)
  73.  
  74. FUNCTION Rmin( A, B: REAL ) : REAL;
  75.  
  76. (*----------------------------------------------------------------------*)
  77. (*                                                                      *)
  78. (*   Function: Rmin                                                     *)
  79. (*                                                                      *)
  80. (*   Purpose:  Returns smaller of two real numbers                      *)
  81. (*                                                                      *)
  82. (*   Calling sequence:                                                  *)
  83. (*                                                                      *)
  84. (*      Smaller := RMIN( A , B : REAL ) : REAL;                         *)
  85. (*                                                                      *)
  86. (*         A       --- 1st input real number                            *)
  87. (*         B       --- 2nd input real number                            *)
  88. (*         Smaller --- smaller of A, B returned                         *)
  89. (*                                                                      *)
  90. (*                                                                      *)
  91. (*   Calls:  None                                                       *)
  92. (*                                                                      *)
  93. (*                                                                      *)
  94. (*----------------------------------------------------------------------*)
  95.  
  96. BEGIN (* Rmin *)
  97.  
  98.    IF A < B THEN
  99.       Rmin := A
  100.    ELSE
  101.       Rmin := B;
  102.  
  103. END   (* Rmin *);
  104.  
  105. (*----------------------------------------------------------------------*)
  106. (*               Rmax --- Find maximum of two reals                     *)
  107. (*----------------------------------------------------------------------*)
  108.  
  109. FUNCTION Rmax( A, B: REAL ) : REAL;
  110.  
  111. (*----------------------------------------------------------------------*)
  112. (*                                                                      *)
  113. (*   Function:  Rmax                                                    *)
  114. (*                                                                      *)
  115. (*   Purpose:   Returns larger of two real numbers                      *)
  116. (*                                                                      *)
  117. (*   Calling sequence:                                                  *)
  118. (*                                                                      *)
  119. (*      Larger := RMAX( A , B : REAL ) : REAL;                          *)
  120. (*                                                                      *)
  121. (*         A       --- 1st input real number                            *)
  122. (*         B       --- 2nd input real number                            *)
  123. (*         Larger  --- Larger of A, B returned                          *)
  124. (*                                                                      *)
  125. (*                                                                      *)
  126. (*   Calls:  None                                                       *)
  127. (*                                                                      *)
  128. (*----------------------------------------------------------------------*)
  129.  
  130. BEGIN (* Rmax *)
  131.  
  132.    IF A > B THEN
  133.       Rmax := A
  134.    ELSE
  135.       Rmax := B;
  136.  
  137. END   (* Rmax *);
  138.